// 维护一个 length = 10 的窗口，每次将窗口内的字符串存进 map 中
// 当第二次遇到同样字符串，+1 即可

var findRepeatedDnaSequences = function (s) {
  let len = s.length;
  if (len <= 10) return [];
  let res = [],
    left = 0,
    right = 10,
    map = new Map();
  while (right <= len) {
    let curr = s.substring(left, right);
    map.set(curr, map.has(curr) ? map.get(curr) + 1 : 1);
    left++;
    right++;
  }
  for (const [key, value] of map) {
    if (value > 1) res.push(key);
  }
  return res;
};
